import 'package:ladder_cash/app/app.dart';
import 'package:ladder_cash/app/com/view/carousel_view.dart';
import 'package:ladder_cash/app/key_mix.dart';
import 'package:ladder_cash/app/page/component/dashed_line.dart';
import 'package:ladder_cash/config/super_theme.dart';
import 'package:ladder_cash/generated/l10n.dart';
import 'package:ladder_cash/value/app_const.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:liuxlcommon/view/lxl_widget.dart';
import 'package:liuxlcommon/view/my_box.dart';
import 'package:liuxlcommon/view/my_style.dart';
import 'package:ladder_cash/app/page/index/index_logic.dart';
import 'package:ladder_cash/generated/assets.dart' as mAssets;
import '../../../../Global.dart';
import '../../../../gen/assets.gen.dart';
import '../../../../library/src/logger.dart';
import '../../component/common.dart';
import '../../component/decoration_bg.dart';
import '../../component/liner_text.dart';
import '../../component/product_detail.dart';

/// 大卡位
class LargeCard extends StatefulWidget {
  @override
  _LargeCardState createState() => _LargeCardState();
}

class _LargeCardState extends State<LargeCard> {
  IndexLogic logic = Get.find<IndexLogic>();

  @override
  void didChangeDependencies() {
    super.didChangeDependencies();
    // precacheImage(const AssetImage(Assets.bgSmallCardBg), context);
  }

  @override
  Widget build(BuildContext context) => abody;

  List<Widget> getList(){
    return logic.antesDeList.map((ele){
      return Container(
        margin: EdgeInsets.only(top: 12.w),
        decoration: BoxDecoration(
            borderRadius: getTopRadius(isAll: true),
            color: SuperTheme.lightBgPrimary
        ),
        child: Row(
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            Container(
              alignment: Alignment.center,
              width: 28.w,
              height: 28.w,
              decoration: BoxDecoration(
                  color: const Color(0xff51780E),
                  borderRadius: getTopRadius(radius: 20,isAll: true)
              ),
              child:  middleFont(ele['title'],fontFamily: "Italic",fontsize: 14),
            ),
            12.lsw,
            middleFont(ele['content'],fontsize: 14)
          ],
        ),
      );
    }).toList();
  }
  get tbg => LColumn.eazy([
        30.lsh,
        LRow.eazy([
          35.lsw,
          LImage.easy("${data['productLogo'.hx]}", 25.w, 25.w, 5.w),
          6.lsw,
          LText.easy("${data['productName'.hx]}111", 16.sp, fw8, Colors.white)
              .flex(1),
        ]),
        13.lsh,
        LText.easy(data['amountRangeDes'.hx], 15.sp, null, Colors.white)
            .size(null, 18.w),
        7.lsh,
        LText.easy(
                data?['amountRange'.hx], 40.sp, FontWeight.bold, Colors.white)
            .size(null, 48.w),
        10.lsh,
        LRow.eazy([
          LText.easy(data['termInfoDes'.hx] + ":", 12.sp, null, Colors.white),
          LText.easy(data['termInfo'.hx], 12.sp, null, Colors.white),
          10.lsw,
          LText.easy(data['loanRateDes'.hx] + ":", 12.sp, null, Colors.white),
          LText.easy(data['loanRate'.hx], 12.sp, null, Colors.white),
        ]).size(null, 18.w),
        52.lsh,
        LText.easy(data['buttonText'.hx], 18.sp, fw7, Colors.white),
      ])
          .bgImg(mAssets.Assets.molopNewLacar)
          .size(375.w, 270.w)
          .onTapL(() => logic.clickApply(data));

  // get topbox => LRow.eazy([
  //       LImage.easy(Assets.pcLargekf, 32.w, 32.w).onTapL(() {
  //         if (logic.indexData != null) {
  //           Get.to(MyWebPage(url: logic.indexData!['icon'.hx]['linkUrl'.hx]));
  //         }
  //       }),
  //       16.lsw,
  //     ]);
  //

  get t1css => '''height: 17px;
font-size: 12px; 
font-weight: 500; 
color: #999999;''';

  get t2css => '''
  text-align:center;
  flex:1;font-weight: 500;
font-size: 15px;
color: #FFFFFF;''';

  // 'termInfo' : 'stretch',
  // 'termInfoDes' : 'indications',
  // 'loanRate' : 'mainly',
  // 'loanRateDes' : 'subdominant',

  get data => logic.largeCardData ?? {};

  List banners = [
    mAssets.Assets.molopNewB1bg,
    mAssets.Assets.molopNewB2bg,
    mAssets.Assets.molopNewB3bg
  ];
  String aboutDetail() {
    if (logic.aboutState == 0) {
      return S.current.withThe;
    } else if (logic.aboutState == 1) {
      return S.current.complianceContent;
    } else {
      return S.current.intelligentContent;
    }
  }

  get abody => GetBuilder<IndexLogic>(builder: (logic) {
        return ListView(
          padding: EdgeInsets.zero,
          children: [
            LStack([
              Container(
                width: 375.w,
                height: 1440.w,
                color: SuperTheme.primary,
              ),
              Positioned(
                  top: 0,
                  width: Global.width,
                  child: Container(
                    width: Global.width,
                    padding: EdgeInsets.symmetric(horizontal: 12.w),
                    height: 842.w,
                    decoration: BoxDecoration(
                        image: getDecorationBg(Assets.home.home95251Bg.path)),
                    child: Column(
                      mainAxisAlignment: MainAxisAlignment.spaceAround,
                      crossAxisAlignment: CrossAxisAlignment.center,
                      children: [
                        getProductDetail(
                            title: S.current.appName,
                            amountRange: '${data?['amountRange'.hx]}',
                            loanRate: data['loanRate'.hx],
                            termInfo: data['termInfo'.hx],
                            termInfoDes: data['termInfoDes'.hx] ,
                            loanRateDes:"${data['loanRateDes'.hx]}"),
                        SizedBox(
                          height: 56.w,
                          child: commonBtn(data['buttonText'.hx],
                              isShowRight: true,
                              img: Assets.home.home9528Btn.path, callback: () {
                            logic.clickApply(data);
                          }),
                        ),
                        SizedBox(
                          height: 30.w,
                        ),
                        if (App.localeEn)
                          Container(
                            padding: EdgeInsets.all(16.w),
                            height: 188.w,
                            decoration: BoxDecoration(
                                image: getDecorationBg(
                                    Assets.home.home9527Bg.path)),
                            child: Column(
                              crossAxisAlignment: CrossAxisAlignment.center,
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              children: [
                                Row(
                                  mainAxisAlignment: MainAxisAlignment.start,
                                  children: [
                                    Image.asset(
                                      Assets.home.home9527Hand.path,
                                      width: 30.w,
                                      height: 30.w,
                                    ),
                                    SizedBox(
                                      width: 10.w,
                                    ),
                                    middleFont(S.current.qualifications,
                                        fontsize: 26.sp,
                                        fontWeight: FontWeight.w900,
                                        fontFamily: 'italic'),
                                  ],
                                ),
                                Row(
                                  mainAxisAlignment:
                                      MainAxisAlignment.spaceBetween,
                                  children: [
                                    Image.asset(
                                      Assets.home.img1.path,
                                      width: 49.w,
                                      height: 49.w,
                                    ),
                                    Image.asset(
                                      Assets.home.img2.path,
                                      width: 108.w,
                                      height: 49.w,
                                    ),
                                    Image.asset(
                                      Assets.home.img3.path,
                                      width: 116.w,
                                      height: 49.w,
                                    ),
                                  ],
                                ),
                                middleFont(S.current.ensureThat,
                                    fontsize: 14.sp)
                              ],
                            ),
                          )
                        else
                          Container(
                            child:Column(
                              children: [
                                middleFont(S.current.antesDe,
                                    fontsize: 15.sp,
                                    textAlign: TextAlign.start,
                                    fontWeight: FontWeight.w900,
                                    fontFamily: 'italic',),
                                ...getList()

                              ],
                            ) ,
                            padding: EdgeInsets.all(16.w),
                            height: 188.w,
                            decoration: BoxDecoration(
                                image: getDecorationBg(
                                    Assets.home.home9527Bg.path)),
                          ),
                        SizedBox(
                          height: 12.w,
                        ),
                        Container(
                          padding: EdgeInsets.all(16.w),
                          height: 240.w,
                          decoration: BoxDecoration(
                              image:
                                  getDecorationBg(Assets.home.home9527Bg.path)),
                          child: Column(
                            crossAxisAlignment: CrossAxisAlignment.center,
                            children: [
                              Row(
                                mainAxisAlignment: MainAxisAlignment.start,
                                children: [
                                  Image.asset(
                                    Assets.home.home9527People.path,
                                    width: 30.w,
                                    height: 30.w,
                                  ),
                                  SizedBox(
                                    width: 10.w,
                                  ),
                                  middleFont(S.current.aboutUs,
                                      fontsize: 26.sp,
                                      fontWeight: FontWeight.w900,
                                      fontFamily: 'italic'),
                                ],
                              ),
                              LSizeH(8),
                              Stack(
                                children: [
                                  SizedBox(
                                    width: 320.w,
                                    height: 28.w,
                                  ),
                                  Positioned(
                                    left: 0,
                                    child: InkWell(
                                      onTap: () {
                                        logic.changeState(0);
                                      },
                                      child: Container(
                                        alignment: Alignment.center,
                                        width: 110.w,
                                        height: 28.w,
                                        decoration: BoxDecoration(
                                            image: getDecorationBg(
                                                logic.aboutState == 0
                                                    ? Assets.home.home95271.path
                                                    : Assets.home.home95272Chat
                                                        .path)),
                                        child: middleFont(S.current.fast,
                                            fontsize: 14.sp),
                                      ),
                                    ),
                                  ),
                                  Positioned(
                                    left: 104.w,
                                    child: InkWell(
                                      onTap: () {
                                        logic.changeState(1);
                                      },
                                      child: Container(
                                        width: 110.w,
                                        height: 28.w,
                                        alignment: Alignment.center,
                                        decoration: BoxDecoration(
                                            image: getDecorationBg(
                                                logic.aboutState == 1
                                                    ? Assets.home.home95272.path
                                                    : Assets.home.home95272Chat
                                                        .path)),
                                        child: middleFont(S.current.compliance,
                                            fontsize: 14.sp),
                                      ),
                                    ),
                                  ),
                                  Positioned(
                                    right: 0,
                                    child: InkWell(
                                      onTap: () {
                                        logic.changeState(2);
                                      },
                                      child: Container(
                                        width: 110.w,
                                        height: 28.w,
                                        alignment: Alignment.center,
                                        child: middleFont(S.current.intelligent,
                                            fontsize: 14.sp),
                                        decoration: BoxDecoration(
                                            image: getDecorationBg(
                                                logic.aboutState == 2
                                                    ? Assets.home.home95273.path
                                                    : Assets
                                                        .home.home952733.path)),
                                      ),
                                    ),
                                  )
                                ],
                              ),
                              Container(
                                alignment: Alignment.center,
                                padding: EdgeInsets.all(16.w),
                                width: 320.w,
                                height: 126.w,
                                child: middleFont(aboutDetail(),
                                    textAlign: TextAlign.start,
                                    fontsize: 14.sp),
                                decoration: BoxDecoration(
                                    image: getDecorationBg(
                                        Assets.home.home95271Chat.path)),
                              )
                            ],
                          ),
                        ),
                      ],
                    ),
                  )),
              Positioned(
                  width: Global.width,
                  top: 850.w,
                  child: Container(
                      padding: EdgeInsets.symmetric(horizontal: 12.w),
                      height: 513.w,
                      decoration: BoxDecoration(
                        color: SuperTheme.primary,
                      ),
                      child: Container(
                        padding: EdgeInsets.only(left: 20.w, right: 20.w),
                        height: 485.w,
                        decoration: BoxDecoration(
                            image:
                                getDecorationBg(Assets.home.home9530Bg.path)),
                        child: Column(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          children: [
                            Container(
                              padding: EdgeInsets.only(top: 13.w),
                              height: 66.w,
                              child: middleFont(S.current.howTo,
                                  fontFamily: 'italic',
                                  fontWeight: FontWeight.w900,
                                  fontsize: 26.sp,
                                  textAlign: TextAlign.start),
                            ),
                            Container(
                              height: 135.w,
                              child: Row(
                                crossAxisAlignment: CrossAxisAlignment.center,
                                children: [
                                  Padding(
                                    padding: EdgeInsets.only(right: 20.w),
                                    child: Image.asset(
                                     App.localeEn? Assets.home.step1.path :Assets.home.homeEs1Bg.path,
                                      width: 117.w,
                                      height: 91.w,
                                    ),
                                  ),
                                  Expanded(
                                      child: Column(
                                    crossAxisAlignment:
                                        CrossAxisAlignment.start,
                                    mainAxisAlignment: MainAxisAlignment.center,
                                    children: [
                                      Container(
                                        width: 83.w,
                                        height: 18.w,
                                        decoration: BoxDecoration(
                                          image: getDecorationBg(
                                              Assets.home.home9527Step.path),
                                        ),
                                        child: middleFont(S.current.step01,
                                            fontWeight: FontWeight.w900,
                                            fontsize: 18.sp,
                                            fontFamily: 'italic'),
                                      ),
                                      SizedBox(
                                        height: 15.w,
                                      ),
                                      middleFont(S.current.step01Content,
                                          fontWeight: FontWeight.w500,
                                          fontsize: 14.sp,
                                          textAlign: TextAlign.start)
                                    ],
                                  ))
                                ],
                              ),
                            ),
                            DashedLine(),
                            Container(
                              height: 135.w,
                              child: Row(
                                crossAxisAlignment: CrossAxisAlignment.center,
                                children: [
                                  Padding(
                                    padding: EdgeInsets.only(right: 20.w),
                                    child: Image.asset(
                                     App.localeEn? Assets.home.step2.path:Assets.home.homeEs2Bg.path,
                                      width: 117.w,
                                      height: 91.w,
                                    ),
                                  ),
                                  Expanded(
                                      child: Column(
                                    crossAxisAlignment:
                                        CrossAxisAlignment.start,
                                    mainAxisAlignment: MainAxisAlignment.center,
                                    children: [
                                      Container(
                                        width: 83.w,
                                        height: 18.w,
                                        decoration: BoxDecoration(
                                          image: getDecorationBg(
                                              Assets.home.home9527Step.path),
                                        ),
                                        child: middleFont(S.current.step02,
                                            fontWeight: FontWeight.w900,
                                            fontsize: 18.sp,
                                            fontFamily: 'italic'),
                                      ),
                                      SizedBox(
                                        height: 10.w,
                                      ),
                                      middleFont(S.current.step02Content,
                                          fontWeight: FontWeight.w500,
                                          fontsize: 14.sp,
                                          textAlign: TextAlign.start)
                                    ],
                                  ))
                                ],
                              ),
                            ),
                            DashedLine(),
                            Container(
                              height: 135.w,
                              child: Row(
                                crossAxisAlignment: CrossAxisAlignment.center,
                                children: [
                                  Padding(
                                    padding: EdgeInsets.only(right: 20.w),
                                    child: Image.asset(
                                    App.localeEn ?  Assets.home.step3.path :Assets.home.homeEs3Bg.path,
                                      width: 117.w,
                                      height: 91.w,
                                    ),
                                  ),

                                  Expanded(
                                      child: Column(
                                    crossAxisAlignment:
                                        CrossAxisAlignment.start,
                                    mainAxisAlignment: MainAxisAlignment.center,
                                    children: [
                                      Container(
                                        width: 83.w,
                                        height: 18.w,
                                        decoration: BoxDecoration(
                                          image: getDecorationBg(
                                              Assets.home.home9527Step.path),
                                        ),
                                        child: middleFont(S.current.step03,
                                            fontWeight: FontWeight.w900,
                                            fontsize: 18.sp,
                                            fontFamily: 'italic'),
                                      ),

                                      SizedBox(
                                        height: 15.w,
                                      ),
                                      middleFont(S.current.step03Content,
                                          fontWeight: FontWeight.w500,
                                          fontsize: 14.sp,
                                          textAlign: TextAlign.start)
                                    ],
                                  ))
                                ],
                              ),
                            ),
                          ],
                        ),
                      )))
            ])
          ],
        );
      });

}
